package logic

import (
	"context"

	"hzjt-oam/rpc/sys/internal/svc"
	"hzjt-oam/rpc/sys/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetSysRoleDeptByIdLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetSysRoleDeptByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetSysRoleDeptByIdLogic {
	return &GetSysRoleDeptByIdLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GetSysRoleDeptByIdLogic) GetSysRoleDeptById(in *pb.GetSysRoleDeptByIdReq) (*pb.GetSysRoleDeptByIdResp, error) {
	one, err := l.svcCtx.RoleDeptModel.FindOne(l.ctx, in.Id)
	if err != nil {
		return nil, err
	}

	var role_dept = &pb.SysRoleDept{
		Id:             one.Id,
		RoleId:         one.RoleId,
		DeptId:         one.DeptId,
		CreateBy:       one.CreateBy,
		CreateTime:     one.CreateTime,
		LastUpdateBy:   one.LastUpdateBy,
		LastUpdateTime: one.LastUpdateTime,
	}

	return &pb.GetSysRoleDeptByIdResp{SysRoleDept: role_dept}, nil
}
